﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Hxj.Web;
using Hxj.Data.Common;
using RicciWebsite.Model;
using Hxj.Common;

namespace RicciWebsite
{
    public partial class message : RicciWebsite.Pages.PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            RicciWebsite.masterpage._default m = this.Master.Master as RicciWebsite.masterpage._default;
            m.TabIndex = 5;
        }


        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnMessage_Click(object sender, EventArgs e)
        {
            if (!IsValid)
                return;

            string authnum = Common.GetVerifycodeCookie();
            if (string.Compare(authnum, txtauthnum.Text, true) != 0)
            {
                JavaScript.MsgBox(GetLocalResourceObject("AuthnumError").ToString());
                return;
            }

            if (!Validator.IsEmail(txtemail.Text))
            {
                JavaScript.MsgBox(GetLocalResourceObject("EmailError").ToString());
                return;
            }

            base_message messageModel = new base_message();
            //EntityUtils.UpdateModel<base_message>(messageModel, "txt");
            messageModel.email = txtemail.Text;
            messageModel.mcontent = txtmcontent.Text;
            messageModel.mtitle = txtmtitle.Text.Trim();
            messageModel.uname = txtuname.Text;
            messageModel.mid = Guid.NewGuid().ToString();
            messageModel.subtime = DateTime.Now;
            messageModel.subip = Request.UserHostAddress;
            messageModel.status = 0;

            RicciDatabase.Default.Insert<base_message>(messageModel);

            JavaScript.MsgBox_Redirect_End(GetLocalResourceObject("ThanksInformation").ToString(), "message.aspx");

        }
    }
}
